package service.Impl;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import dao.AppInfoMapper;
import entity.App_category;
import entity.App_info;
import entity.App_version;
import entity.Data_dictionary;
import service.AppInfoService;
import tools.PageSupport;

@Service("Query")
public class AppInfoServiceImpl implements AppInfoService {
	
	@Autowired
	private AppInfoMapper appInfoMapper;

	/**
	 * //����ƽ̨�������ѯ
	 */
	public List<Data_dictionary> Platform() {
		return appInfoMapper.Platform();
	}

	/**
	 * APP״̬�������ѯ
	 */
	public List<Data_dictionary> App() {
		// TODO Auto-generated method stub
		return appInfoMapper.App();
	}

	/**
	 * ��ѯһ������������
	 */
	public List<App_category> One() {
		return appInfoMapper.One();
	}

	/**
	 * ��ѯ����������
	 */
	public List<App_category> Two(Integer id) {
		return appInfoMapper.Two(id);
	}


	/**
	 * ��ѯ�ܼ�¼��
	 */
	public int PageCount(String querySoftwareName, Integer queryStatus, Integer queryCategoryLevel1,
			Integer queryCategoryLevel2, Integer queryCategoryLevel3, Integer queryFlatformId) {
		int count = 0;
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("softwareName", querySoftwareName);
		map.put("status", queryStatus);
		map.put("categoryLevel1", queryCategoryLevel1);
		map.put("categoryLevel2", queryCategoryLevel2);
		map.put("categoryLevel3", queryCategoryLevel3);
		map.put("flatformId", queryFlatformId);
		count = appInfoMapper.PageCount(map);
		return count;
	}

	/**
	 * ��ѯ����APP��Ϣά��
	 */
	public List<App_info> query(String querySoftwareName, Integer queryStatus, Integer queryCategoryLevel1,
			Integer queryCategoryLevel2, Integer queryCategoryLevel3, Integer queryFlatformId, PageSupport page) {
		List<App_info> list = new ArrayList<App_info>();
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("softwareName", querySoftwareName);
		map.put("status", queryStatus);
		map.put("categoryLevel1", queryCategoryLevel1);
		map.put("categoryLevel2", queryCategoryLevel2);
		map.put("categoryLevel3", queryCategoryLevel3);
		map.put("flatformId", queryFlatformId);
		map.put("currentPageNo",(page.getCurrentPageNo()-1)*5);
		list = appInfoMapper.query(map);
		return list;
	}

	/**
	 * ����idɾ��APP��Ϣ
	 */
	public int dele(Integer delId) {
		return appInfoMapper.dele(delId);
	}

	/**
	 * ����id��ѯ��ϸ��Ϣ
	 */
	public App_info Appquery(Integer Id) {
		return appInfoMapper.Appquery(Id);
	}

	/**
	 * ����id��ѯ��ʷ�汾
	 */
	public List<App_version> Appchaxun(Integer Id) {
		return appInfoMapper.Appchaxun(Id);
	}

	/**
	 * ����ҳ������ƽ̨�������ѯ
	 */
	public List<Data_dictionary> Addping(String typecode) {
		return appInfoMapper.Addping(typecode);
	}

	/**
	 * ����ҳ��һ�������������ѯ
	 */
	public List<App_category> One1() {
		return appInfoMapper.One1();
	}

	/**
	 * ��������
	 */
	public int insert(App_info app_info) {
		return appInfoMapper.insert(app_info);
	}

	/**
	 * ��֤APK�����Ƿ����
	 */
	public int Verification(String APKName) {
		return appInfoMapper.Verification(APKName);
	}

	/**
	 * �޸�ҳ���������ѯ
	 */
	public List<App_category> getAppCategoryListByParentId(Integer parentId) {
		return appInfoMapper.getAppCategoryListByParentId(parentId);
	}

	/**
	 * ����APP�汾��Ϣ
	 */
	public int AddBan(App_version app_version) {
		return appInfoMapper.AddBan(app_version);
	}

	/**
	 * ��ѯAPK����
	 */
	public App_info ApkName(Integer id) {
		return appInfoMapper.ApkName(id);
	}
	
	/**
	 * �޸�app��ϢversionId
	 */
	public Integer updateVersionId(Integer versionId,Integer id) {
		return appInfoMapper.updateVersionId(versionId,id);
	}

	/**
	 * �޸�ͼƬ·��Ϊnull
	 */
	public int updateimages(Integer id) {
		return appInfoMapper.updateimages(id);
	}

	/**
	 * �޸�APP������Ϣ
	 */
	public int updatexinxi(App_info app_info) {
		return appInfoMapper.updatexinxi(app_info);
	}

	/**
	 * ��ʾҪ�޸ĵİ汾��
	 */
	public App_version querybanben(Integer id) {
		return appInfoMapper.querybanben(id);
	}

	/**
	 * ɾ���汾apk·��
	 */
	public int updatebanben(Integer id) {
		return appInfoMapper.updatebanben(id);
	}

	/**
	 * app上下架
	 */
	public int uplower(Integer status, Integer id) {
		
		return appInfoMapper.uplower(status, id);
	}

	public int updatemodiy(App_version app_version) {
		return appInfoMapper.updatemodiy(app_version);
	}

	
	public int delemodiy(Integer id) {
		return appInfoMapper.delemodiy(id);
	}

}
